<?php
$ip = file_get_contents('http://120.26.161.248/ip.html');
$hostpath = 'C:\Windows\System32\drivers\etc\HOSTS';
$hosts = file_get_contents($hostpath);

if (strpos($hosts, $ip) === false)
{
    try {
        $contents = preg_replace('/[0-9].*\sk.dev/', $ip . ' k.dev', $hosts);
        file_put_contents($hostpath, $contents);
    } catch (Exception $e) {
    }
}